package com.sky;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication
@EnableTransactionManagement //开启注解方式的事务管理
@Slf4j
public class SkyApplication {
    public static void main(String[] args) throws Exception {
        // 动态加载类的字节码到JVM（方法区）
//        Class<?> claPerson = Class.forName("com.sky.entity.Employee");
//    // 动态构建对象
//        //Object obj1 = new Employee();
//        Object newPerson = claPerson.newInstance();// 默认调用类的无参构造方法
//    // 动态获取setName方法对象
//        Method methodName = claPerson.getDeclaredMethod("setName",String.class);
//    // 动态获取name属性对象
//        Field fieldName = claPerson.getDeclaredField("name");
//
//        // 动态修改对象的属性，并赋值 person.name = xxx
//        fieldName.setAccessible(true);
//        fieldName.set(newPerson,"wangwu");
//        System.out.println(fieldName.get(newPerson).toString());
//        // 动态调用方法，person.setName
//        methodName.invoke(newPerson,"zhangsan");
//        System.out.println(fieldName.get(newPerson).toString());



        SpringApplication.run(SkyApplication.class, args);
        log.info("server started");
    }
}
